package com.example.oauth.tracing.config;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;

import java.util.Arrays;
import java.util.List;

@RefreshScope
@ConfigurationProperties("opentracing.jaeger")
public class JaegerConfigurationExtraProperties {

    private final RemoteReporterExtraConfig remoteReporter = new RemoteReporterExtraConfig();

    /**
     * 默认最大10k
     */
    @Setter
    @Getter
    private int maxLogContentSize = 10240;

    public RemoteReporterExtraConfig getRemoteReporter() {
        return remoteReporter;
    }

    @Data
    public static class RemoteReporterExtraConfig {

        // 数据库操作<50ms的trace默认不上报
        private List<String> skipPatterns = Arrays.asList(
                "operationName=='Execute' and duration < 50000",
                "operationName=='Query' and duration < 50000"
        );

    }

}

